<template>
	<view>
		<view style="min-height:520rpx;max-height:88vh;overflow-y: auto;">
			<view class="coupon-card" v-for="(item,index) in couponList"  :key="item.id">
				<!-- <view style="position: absolute;word-wrap: break-word;width:20px;height:120rpx;right: 0;top: 0;">已失效</view> -->
				<view style="position: relative;overflow: hidden;">
					<view v-if="current==3" class="expired-style">已失效</view>
					<view>
						<text v-if="current==3 && item.tag" class="new-tag gray">{{item.tag}}</text>
						<text v-if="current!=3 && item.tag" class="new-tag">{{item.tag}}</text>
					</view>
					<view class="coupon-content">
						<view class="coupon-item left">
							<view :class="current==3 ? 'title-bold size14 gray' :'title-bold size14'">{{item.name}}</view>
							<text class="gray-color size12">{{item.tips}}</text>
						</view>
						<view class="coupon-item right">
							<view class="money" v-if="current==3">
								<!-- 失效 -->
								<text class="money-icon gray">￥</text><text class="money-val gray">{{item.coupon_money || ''}}</text>
							</view>
							<view class="money" v-else>
								<text class="money-icon">￥</text><text class="money-val">{{item.coupon_money || ''}}</text>
							</view>
							<text class="gray-color size12" style="padding-right:30rpx;">{{item.limit_name}}</text>
						</view>
					</view>
					<view class="coupon-date">
						<view class="gray-color date-range size12">{{item.startTime}}至{{item.endTime}}</view>
						<!-- 暂时隐藏去使用入口 -->
						<!-- <view class="coupon-state" v-if="current==0" @click="toUse(item,index)">去使用</view> -->
						<view class="coupon-state" v-if="current==1"  @click="toGet(item,index)">领取</view>
						<view class="coupon-state gray" v-if="current==3"  @click="toGet(item,index)">去使用</view>
					</view>
				</view>
			</view>
			<view v-if="couponList.length==0" style="text-align: center;margin-top:70rpx;">
				<slot name='noData'>暂无数据</slot>
			</view>
			<view class="complete-coupon">
				<slot name="coupon-footer-complete">
				</slot>
			</view>
		</view>
	</view>
</template>
<script>
	import bottomPopup from "@/components/bottom-popup/bottom-popup"
	export default {
		name: "couponPopup",
		components: {
			bottomPopup
		},
		watch: {
			show(val) {
				let _this = this;
				if (val) {
					//_this.active = 0; //每次打开默认满减
					_this.localCouponId = _this.couponId;
								}

			}
		},
		onShow() {
			console.log(this.couponList)
		},
		// props:['mask', 'couponList','showCouponPopup'],//父组件传过来的数据
		props: {
			current: {
				type: Number,
				default: 0
			},
			couponId: {
				type: String,
				default: ''
			},
			couponList: {
				type: Array,
				default: []
			},
			tabCouponArr: {
				type: Array,
				default: []
			},
			showCouponPopup: {
				type: Boolean,
				default: false
			},
			//是否需要mask
			mask: {
				type: Boolean,
				default: true
			},
			//控制显示
			show: {
				type: Boolean,
				default: false
			},
			//背景颜色
			bgcolor: {
				type: String,
				default: "#fff"
			},
			//高度 rpx
			height: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				active: 0,
				currentCoupon: null,
				localCouponId: '',
				checked: false,
			}
		},
		methods: {
			couponTab(i) {
				let _this = this;
				_this.active = i;
				this.currentCoupon = null;
				_this.$emit('getCouponType', this.active)
			},
			toUse(item, index) {
				console.log(item.url)
				let _this = this;
				if(this.current==0){
					uni.navigateTo({
						url:item.tourl
					})
				}else{
					return
				}
			},
			toGet(item, index) {
				this.$emit('receive',item.id)
				
			},
			handleClose() {
				this.$emit('maskClose', false);
			}
		}
	}
</script>

<style lang="scss">
	// public
	.tui-bottom-popup {
		width: 100%;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 99999;
		visibility: hidden;
		transform: translate3d(0, 100%, 0);
		transform-origin: center;
		transition: all 0.3s ease-in-out;
		min-height: 20rpx;
	}

	.tui-popup-show {
		transform: translate3d(0, 0, 0);
		visibility: visible;
	}
	.tui-popup-mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.6);
		z-index: 99996;
		transition: all 0.3s ease-in-out;
		opacity: 0;
		visibility: hidden;
	}
	.tui-mask-show {
		opacity: 1;
		visibility: visible;
	}
	// public
	.size14 {
		font-size: 28rpx;
	}
	.size12 {
		font-size: 24rpx;
	}
	.tab-coupon {
		padding-top: 30rpx;
		display: flex;
		flex-direction: row;
		height: 50rpx;
		align-items: center;
		font-size: 32rpx;
		font-weight: bold;
		text {
			padding: 20rpx;
		}
		.active {
			color: #69A4FE;
		}
		.left-tab-title {
			width: 400rpx;
		}
		.close-icon {
			text-align: right;
			width: 350rpx;
			padding-right: 20rpx;
			font-size: 40rpx;
		}
	}
	.title-bold {
		font-weight: bold;
		&.gray{color:gray}
	}
	.close-icon {
		font-size: 40rpx;
		color: #888888;
	}
	.gray-color {
		color: #888888
	}
	.complete-coupon {
		margin: 30rpx;
		button {
			background: #69A4FE !important;
			border-radius: 50rpx;
		}
	}
	.coupon-card {
		background: white;
		display: flex;
		flex-direction: column;
		border: 1px solid #F7F7F7;
		// box-shadow: 0px 0px 5px #E5E5E5;
		margin: 20rpx;
		border-radius: 10rpx;
		height: 260rpx;
		// &::before {
		// 	content: '';
		// 	width: 10px;
		// 	height: 14px;
		// 	position: absolute;
		// 	border: 1px solid #E5E5E5;
		// 	border-radius: 0 50px 50px 0;
		// 	border-left: none;
		// 	left:23px;
		// 	top:122px;
		// 	background: #fff;
		// 	z-index: 99;
		
		// }
		// &::after {
		// 	content: '';
		// 	width: 10px;
		// 	height: 14px;
		// 	position: absolute;
		// 	border: 1px solid #E5E5E5;
		// 	border-radius: 50px 0 0 50px;
		// 	border-right: none;
		// 	right:23px;
		// 	top:122px;
		// 	background: #fff;z-index: 99;
		
		// }
		
		.expired-style{
			position: absolute;
			word-wrap: break-word;
			width: 18px;
			font-size: 24rpx;
			height: 174rpx;
			right: 0rpx;
			top: -47rpx;
			background: gray;
			color: white;
			-webkit-transform: rotate(-48deg);
			transform: rotate(-36deg);
			text-align: center;
			padding-top: 30rpx;
		}
		.new-tag {
			background: #FE9B69;
			width: 140rpx;
			padding: 4rpx 20rpx;
			color: white;
			font-size: 20rpx;
			height: 34rpx;
			border-radius: 10rpx 0rpx 10rpx 0rpx;
			position: relative;
			top: -7rpx;
			&.gray{
				background: gray;
			}
		}
		.coupon-content {
			display: flex;
			flex-direction: row;
			height: 120rpx;

			.coupon-item {
				display: flex;
				flex-direction: column;
				.useRepeat {
					border: 1px solid #FE9B69;
					color: #FE9B69;
					font-size: 20rpx;
					border-radius: 25rpx;
					width: 80rpx;
					text-align: center;
					height: 28rpx;
					line-height: 28rpx;
					padding: 4rpx 14rpx;
					margin-left: 8rpx;
				}

				&.left {
					width: 480rpx;
					padding: 20rpx;
				}

				&.right {
					padding-right:0rpx;
					width: 240rpx;
					text-align: right;
					padding-top:13rpx;
					.money {
						color: #FF7A36;text-align:right;padding-right: 30rpx;
						.money-val {
							font-size:40rpx;font-weight: bold;
							&.gray{color: gray;}
						}

						.money-icon {
							font-size:28rpx;font-weight: bold;
							&.gray{color: gray;}
						}
					}

				}
			}
		}

		.coupon-date {
			padding-left: 20rpx;
			position: relative;
			border-top: 1rpx solid #F7F7F7;
			padding-top: 30rpx;
			position: relative;
			height: 120rpx;

			&::before {
				content: '';
				width: 10px;
				height: 14px;
				position: absolute;
				border: 1px solid #F7F7F7;
				border-radius: 0 50px 50px 0;
				border-left: none;
				left: -2px;
				top: -10px;
				background: #F7F7F7;
			}
			&::after {
				content: '';
				width: 10px;
				height: 14px;
				position: absolute;
				border: 1px solid #F7F7F7;
				border-radius: 50px 0 0 50px;
				// border-left: 1px solid #fff;
				border-right: none;
				right: -2px;
				top: -10px;
				background: #F7F7F7;
			}
			

			.date-range {
				position: relative;
				top: -2rpx;
			}

			.coupon-state {
				position: absolute;
				padding:0rpx 20rpx;
				height: 44rpx;
				line-height:40rpx;
				right:30rpx;
				bottom:76rpx;
				background: #69A4FE;
				color: white;
				// border-radius: 50rpx 0 0 50rpx;
				border-radius:25px;
				font-size:24rpx;
				text-align: center;
				&.gray{
					background: gray;
				}
			}
		}
	}
</style>
